Optimize the case where a component is entirely transparent by skipping
authorOwen Taylor <otaylor@redhat.com>
Mon, 28 Jan 2002 05:34:17 +0000 (05:34 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 28 Jan 2002 05:34:17 +0000 (05:34 +0000)
Sun Jan 27 23:58:13 2002  Owen Taylor  <otaylor@redhat.com>

        * pixbuf-render.c (compute_hint): Optimize the case
        where a component is entirely transparent by skipping
        drawing it.

        * pixbuf-rc-style.c (theme_parse_image): Catch case
        where background or overlay border/stretch are specified
        without a background image.

        * pixbuf-render.c (theme_pixbuf_destroy): Actually free
        the structure and filename.

modules/engines/pixbuf/ChangeLog
modules/engines/pixbuf/Makefile.am
modules/engines/pixbuf/pixbuf-draw.c
modules/engines/pixbuf/pixbuf-rc-style.c
modules/engines/pixbuf/pixbuf-render.c
modules/engines/pixbuf/pixbuf.h

index cc8e0f4e13c6da1a3372e36379d10510f1ae66d3..b1cc574825ec978a60aff2693201bd18b57a837c 100644 (file)
@@ -1,3 +1,16 @@
+Sun Jan 27 23:58:13 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * pixbuf-render.c (compute_hint): Optimize the case
+       where a component is entirely transparent by skipping
+       drawing it.
+
+       * pixbuf-rc-style.c (theme_parse_image): Catch case
+       where background or overlay border/stretch are specified
+       without a background image.
+
+       * pixbuf-render.c (theme_pixbuf_destroy): Actually free
+       the structure and filename.
+
 =================== Move back into gtk-engines ====================
        
 Sat Jan 19 02:45:17 2002  Owen Taylor  <otaylor@redhat.com>
index 22bb327e825d94352a912bdba567a62083ea77b3..d3e6bdef40a148df19f1770a6ce204f7f0244958 100644 (file)
@@ -14,3 +14,7 @@ libpixmap_la_SOURCES =                \
        pixbuf.h
 
 libpixmap_la_LDFLAGS =  -avoid-version -module
+
+dist-hook:
+       cp -pr examples $(distdir);                                     \
+        find $(distdir)/examples -name 'CVS' -print | xargs rm -rf 
index ab192a446ea6155aa73d7651d056f4f5f005fecd..2fe5bc64127efafcd84346fed28dc1f31357653e 100644 (file)
@@ -659,9 +659,10 @@ draw_box (GtkStyle     *style,
   match_data.state = state;
 
   if (!draw_simple_image (style, window, area, widget, &match_data, TRUE, TRUE,
-                         x, y, width, height))
+                         x, y, width, height)) {
     parent_class->draw_box (style, window, state, shadow, area, widget, detail,
                            x, y, width, height);
+  }
 }
 
 static void
index 6fbb92fb15f5b69a0a001faf848ea9277e25dcf2..210b0f5256c951a453a9ee67339262e37da8cb48 100644 (file)
@@ -664,6 +664,20 @@ theme_parse_image(GtkSettings  *settings,
 
   token = g_scanner_get_next_token(scanner);
 
+  if (data->background && !data->background->filename)
+    {
+      g_scanner_warn (scanner, "Background image options specified without filename");
+      theme_pixbuf_destroy (data->background);
+      data->background = NULL;
+    }
+
+  if (data->overlay && !data->overlay->filename)
+    {
+      g_scanner_warn (scanner, "Overlay image options specified without filename");
+      theme_pixbuf_destroy (data->overlay);
+      data->overlay = NULL;
+    }
+
   if (token != G_TOKEN_RIGHT_CURLY)
     {
       /* error - cleanup for exit */
index 08201f330f88c5f40e66e65235b87e9d4481511a..d34632b23645fa66bef7edffdd63e0d5da47f0a3 100644 (file)
@@ -180,6 +180,9 @@ pixbuf_render (GdkPixbuf    *src,
   rect.width = dest_width;
   rect.height = dest_height;
 
+  if (hints & THEME_MISSING)
+    return;
+
   /* FIXME: Because we use the mask to shape windows, we don't use
    * clip_rect to clip what we draw to the mask, only to clip
    * what we actually draw. But this leads to the horrible ineffiency
@@ -290,8 +293,8 @@ theme_pixbuf_new (void)
 void
 theme_pixbuf_destroy (ThemePixbuf *theme_pb)
 {
-  if (theme_pb->pixbuf)
-    g_cache_remove (pixbuf_cache, theme_pb->pixbuf);
+  theme_pixbuf_set_filename (theme_pb, NULL);
+  g_free (theme_pb);
 }
 
 void         
@@ -307,7 +310,10 @@ theme_pixbuf_set_filename (ThemePixbuf *theme_pb,
   if (theme_pb->filename)
     g_free (theme_pb->filename);
 
-  theme_pb->filename = g_strdup (filename);
+  if (filename)
+    theme_pb->filename = g_strdup (filename);
+  else
+    theme_pb->filename = NULL;
 }
 
 static guint
@@ -318,7 +324,7 @@ compute_hint (GdkPixbuf *pixbuf,
              gint       y1)
 {
   int i, j;
-  int hints = THEME_CONSTANT_ROWS | THEME_CONSTANT_COLS;
+  int hints = THEME_CONSTANT_ROWS | THEME_CONSTANT_COLS | THEME_MISSING;
   int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
   
   guchar *data = gdk_pixbuf_get_pixels (pixbuf);
@@ -340,13 +346,21 @@ compute_hint (GdkPixbuf *pixbuf,
 
       for (j = x0 + 1; j < x1 ; j++)
        {
+         if (n_channels != 4 || p[4] != 0)
+           {
+             hints &= ~THEME_MISSING;
+             if (!(hints & THEME_CONSTANT_ROWS))
+               goto cols;
+           }
+         
          if (r != *(p++) ||
              g != *(p++) ||
              b != *(p++) ||
-             (n_channels == 4 && a != *(p++)))
+             (n_channels != 4 && a != *(p++)))
            {
              hints &= ~THEME_CONSTANT_ROWS;
-             goto cols;
+             if (!(hints & THEME_MISSING))
+               goto cols;
            }
        }
     }
index 34dfeb61c08b2bcd82d6fbeee2c09156c9345415..2638fc87bd547171dfae6727110182adfa54301d 100644 (file)
@@ -121,7 +121,8 @@ typedef enum {
 
 typedef enum {
   THEME_CONSTANT_ROWS = 1 << 0,
-  THEME_CONSTANT_COLS = 1 << 1
+  THEME_CONSTANT_COLS = 1 << 1,
+  THEME_MISSING = 1 << 2
 } ThemeRenderHints;
 
 struct _ThemePixbuf